package com.hq.es.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.EventListener;
import org.springframework.validation.annotation.Validated;

import java.io.IOException;

/**
* @author: lujie
* @create: 2021/4/10
* @description: init  page
**/

@Configuration
@Slf4j
public class IndexConfig {

    @Value("${server.port}")
    String serverPort;


    @EventListener({ApplicationReadyEvent.class})
    void applicationReadyEvent() {
        log.info("Application Init Success !");
        String url = "http://localhost:"+serverPort +"/doc.html";
        Runtime runtime = Runtime.getRuntime();
        try {
            runtime.exec("rundll32 url.dll,FileProtocolHandler " + url);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}